<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>数组扁平化第三种方式</title>
	</head>
	<body>
		<script>
            	let arr = [0, [1, [2, 3, [4, [5, 6]], 7]], [8, 9]]
			function flattenArray(arr) {
				// arr.some 方法返回是否有满足条件（函数标识）的元素  只要是数组就进行拼接
				while (arr.some((item) => Array.isArray(item))) {
					arr = [].concat.apply([], arr)
				}
				return arr
			}

			console.log(flattenArray(arr)) // [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
		</script>
	</body>
</html>
